To generate the series 1+3+5+7+... using C program

Answers were Sorted based on User's Feedback



To generate the series 1+3+5+7+... using C program..

Answer / shiva

for(int a=0;a<10;a++){
(a&1)?printf("%d\n",a):printf("\n");
}

Is This Answer Correct ?    8 Yes 6 No

To generate the series 1+3+5+7+... using C program..

Answer / nasif

#include<stdio.h>
int main()
{
int n,i,d=1,sum=0;
scanf("%d", &n);
for(i=1;i<=n;d=d+2){
sum=sum+d;
i++;
}
printf("summation is %d", sum);
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

To generate the series 1+3+5+7+... using C program..

Answer / meheka

#inclined <stdio.h>
int main ()
{
int I=1,n,sum=0;
scanf("%d",&n);
while(i<=n)
sum=sum+I;
{
printf("%d",sum);
I=I+2;
}
return 0:

Is This Answer Correct ?    1 Yes 0 No

To generate the series 1+3+5+7+... using C program..

Answer / beetha poulose

#include<include>
int main ()
{
int j,i,n,sum=0;
Print("enter n");
scanf ("%d",&n);
For (i=1,j=1; j<=n; i=i+5,j++)
{
Sum=sum +i;
}
Prinrf ("sym=%d",sum);
Return 0;
}

Is This Answer Correct ?    1 Yes 0 No

To generate the series 1+3+5+7+... using C program..

Answer / nishant

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=1,sum=0;
clrscr();
printf("enter the value for n:");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
i=i+2;
}
printf("the series is =%d");
getch()
}

Is This Answer Correct ?    0 Yes 0 No

To generate the series 1+3+5+7+... using C program..

Answer / aditya parashar

#include<iostream.h>
void main ()
{int s,n;
cout <<"For finding sum of series
1+3+5.. till n terms enter value of n: ";
cin>>n;
s=n*n;
cout<<"
sum of series 1+3+5+.. till n
terms is: "<<s;
}
[Note:- only output matters]

Is This Answer Correct ?    0 Yes 0 No

To generate the series 1+3+5+7+... using C program..

Answer / medo

//*I know this is a different program but i want you to try
it!*//



#include <stdio.h>
void main()
{
int i,j;

for(i=1;i<=4;i++)
{
for(j=1;j<=8;j++)
{printf("* ");}
printf("\n");

for(j=1;j<=8;j++)
{printf(" *"); }
printf("\n");
}
}

Is This Answer Correct ?    7 Yes 8 No

To generate the series 1+3+5+7+... using C program..

Answer / parthibanselvaraj

the series seems to be infinite . so you need to restrict
it to some ceiling.

Is This Answer Correct ?    10 Yes 19 No

Post New Answer

More C C++ Errors Interview Questions

who was the present cheif governor of reserve bank of india

6 Answers   State Bank Of India SBI,


what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?

1 Answers  


write a profram for selection sort whats the error in it?

2 Answers  


loop1: { x=i<n?(i++):0; printf("%d",i); exit(x); continue; } Error- misplaced continue. Doubt-1.will the exit(x) be executed for all values of x 2.will this statement go out of the program.

5 Answers   CMC,


how tally is useful?

2 Answers  






what is exceptions?

5 Answers   HCL, Wipro,


void main() { int i=5; printf("%d",i+++++i); }

14 Answers   HCL,


Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .

3 Answers  


full c programming error question based problem

3 Answers   HCL, TCS,


What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).

0 Answers  


#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }

19 Answers  


void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?

24 Answers   HCL,


Categories