ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Write a c code segment using a for loop that calculates and 
prints the sum of the even integers from 2 to 30, inclusive?
 Question Submitted By :: Advsekaran
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?
Answer
# 1
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,sum=0;
clrscr();
printf("enter the starting point :");
scanf("%d",&m);
printf("ending point :");
scanf("%d",&n);
for(int i=m;i<=n;i+=2)
sum+=i;printf("\n\nthe sum is %d:",sum);
getch();
}


thank u
 
Is This Answer Correct ?    4 Yes 0 No
Vignesh1998i
 
  Re: Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?
Answer
# 2
#include<stdio.h>
#include<conio.h>
void main()
{
  int i,no,sum=0;
  clrscr();
  printf("\n entre the no:-");
  scanf("%d",&no);

  for(i=2;i<=30;i+1)
{
   printf("\n the list is %d",i);
  sum=sum+i;
}
  printf("\n the sum is %d",sum);
getch();
}
 
Is This Answer Correct ?    0 Yes 0 No
Parekh Nirav
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
program to get the remainder and quotant of given two numbers with out using % and / operators? IBM8
what is the definition of storage classes? Wipro2
main() { clrscr(); } clrscr(); ME3
how to add numbers without using arithmetic operators. TCS10
without using arithmatic operator convert an intger variable x into x+1  1
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.  2
what is c? Tech-Mahindra5
write a C program to print the program itself ?! TCS12
Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage Accenture5
to find out the reverse digit of a given number Infosys5
6. Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod() Accenture1
In scanf h is used for BFL2
How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?  1
which of the following go out of the loopo if expn 2 becoming false a.while(expn 1){...if(expn 2)continue;} b.while(!expn 1){if(expn 2)continue;...} c.do{..if(expn 1)continue;..}while(expn 2); d.while(!expn 2){if(expn 1)continue;..} TCS2
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation. Global-Edge11
How to find the given no is odd or even without checking of any condition and loops. (Hint: Using array)  4
class foo { public: static int func(const char*& p) const; }; This is illegal, why? Google6
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro? L&T4
to find the program of matrix multiplication using arrays  2
how we can make 3d venturing graphics on outer interface Microsoft1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com