WAP to display 1,2,3,4,5........N

Answers were Sorted based on User's Feedback



WAP to display 1,2,3,4,5........N..

Answer / sreejesh1987

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("\nEnter n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
printf("%d ",i);
getch();
}

Is This Answer Correct ?    11 Yes 3 No

WAP to display 1,2,3,4,5........N..

Answer / arti sharma

void main()
{ int i,n,k;
printf("enter the limit");
scanf("%d",&n);
k=1;
i:
if(k<=n)
{ printf("%d",k);
k++;
goto i;
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }

3 Answers  


why array index always strats wuth zero?

2 Answers  


main() { char not; not=!2; printf("%d",not); }

1 Answers  


void main() { char ch; for(ch=0;ch<=127;ch++) printf(“%c %d \n“, ch, ch); }

1 Answers  






Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }

1 Answers  


What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;

1 Answers  


Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  


main() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user

2 Answers   HCL,


Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.

3 Answers   Wipro,


Categories