1
o 1
1 0 1
0 1 0 1
1 0 1 0 1
how to design this function format in c-language ?

Answers were Sorted based on User's Feedback



1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("enter the terms :");
for(i=1;i<=n;i++)
{
if(i%2==0)
j=1;
else
j=0;
for(k=1;k<=i;k++)
{
j=!j;
printf("%d ",j);
}
printf("\n");
}
getch();
}



thank u

Is This Answer Correct ?    2 Yes 1 No

1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?..

Answer / premkumar

main()

{

int i,j,k=1; clrscr();

for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",k);
if(k==0)k=1;
else k=0;
}
printf("\n");
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

why is printf("%d %d %d",i++,--i,i--);

4 Answers   Apple, Cynity, TCS,


main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }

1 Answers  


Printf can be implemented by using __________ list.

3 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }

1 Answers  






void ( * abc( int, void ( *def) () ) ) ();

1 Answers  


What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


Program to find the largest sum of contiguous integers in the array. O(n)

11 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?

0 Answers  


how can i cast a char type array to an int type array

2 Answers  


Which version do you prefer of the following two, 1) printf(ā€œ%sā€,str); // or the more curt one 2) printf(str);

1 Answers  


Categories