1.

A C program to print n values of following sequence 1 –1 1 –1 1 … is listed below:  

Answer»

#include  <studio.h 

#include<conio.h>

main()

{

int i,j,n,k;

clrscr();

printf("\n enter number \n");

scanf("%d",&n); 

k=1;

for(i=1;i<=n;i++)

{

for(j=1;j<=i;j++)

printf("%d",k);

printf("\t");

}

getch();

}  



Discussion

No Comment Found

Related InterviewSolutions