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

A sample program using data structure? what is file handling?

0 Answers   TCS,


how to convert decimal to binary in c using while loop without using array

50 Answers   Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,


What are the different types of errors in C and when they occur?

4 Answers  


Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.

3 Answers  


I am using Qt 5.6 during compilation it stops and gives error about Qmake The process "C:QtQt5.6.35.6.3msvc2015_64inqmake.exe" crashed. Error while building/deploying project untitled1 (kit: Desktop Qt 5.6.3 MSVC2015 64bit) When executing step "qmake"

0 Answers  






How to reverse a linked list without using array & -1? Thank you.

2 Answers   Access, Satyam,


void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..

32 Answers   College School Exams Tests, CTS, HCL, iGate, SmartData,


how to convert decimal to hexadecimal without using arrays just loops

2 Answers  


Answering Yes or No in C++...using only stdio.h and conio.h..........help me please...? here's must be the output of the program: Screen A Exam No. items Score 1 20 20 2 35 35 Another Entry? [Y] or [N] : Screen B: Record No. Student's Name: 1 Fernando Torres 2 Chuck Norris Note: if you press Y, the program must repeat the procedure in screen A, then if N, the program must proceed to the screen B....Please Help me out............

1 Answers  


Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .

2 Answers  


How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


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

2 Answers  


Categories