Illustrate it
summing the series 2+4+6+......to n terms using
(i) while loop (ii) do-while loop
Answers were Sorted based on User's Feedback
Answer / raju kalyadapu
i). using while-loop
int main()
{
int sum=0,n,i=0,j=2;
printf("Enter 2+4+6+...n upto nth term:");
scanf("%d",&n);
while(i++<n)
{
j=2*i;
sum=sum+i*2;
}
getch();
return 0;
}
ii). using do-while loop
int main()
{
int sum=0,n,i=0,j=2;
printf("Enter 2+4+6+...n upto nth term:");
scanf("%d",&n);
do
{
j=2*i;
sum=sum+i*2;
} while(i++<n);
printf("
Sum of the Series 2+4+6+----%d is:%d",j,sum);
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / srujitha
// while loop
int main()
{
int n = 3,sum = 0,i = 2, count = 0;
while(n > count)
{
sum = sum + i;
i = i+2;
count++;
}
printf("SUM = %d ",sum);
}
// do while loop
int main()
{
int n = 3,sum = 0,i = 2, count = 0;
do
{
sum = sum + i;
i = i+2;
count++;
}
while(n > count);
printf("SUM = %d ",sum);
}
Is This Answer Correct ? | 0 Yes | 0 No |
#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300
What character terminates all strings composed of character arrays? 1) 0 2) . 3) END
1. What is the output of printf("%d") 2. What will happen if I say delete this 3. Difference between "C structure" and "C++ structure". 4. Diffrence between a "assignment operator" and a "copy constructor" 5. What is the difference between "overloading" and "overridding"? 6. Explain the need for "Virtual Destructor". 7. Can we have "Virtual Constructors"? 8. What are the different types of polymorphism? 9. What are Virtual Functions? How to implement virtual functions in "C" 10. What are the different types of Storage classes? 11. What is Namespace? 12. What are the types of STL containers?. 13. Difference between "vector" and "array"? 14. How to write a program such that it will delete itself after exectution? 15. Can we generate a C++ source code from the binary file? 16. What are inline functions? 17. Talk sometiming about profiling? 18. How many lines of code you have written for a single program? 19. What is "strstream" ? 20. How to write Multithreaded applications using C++? 21. Explain "passing by value", "passing by pointer" and "passing by reference" 22. Write any small program that will compile in "C" but not in "C++" 23. Have you heard of "mutable" keyword? 24. What is a "RTTI"? 25. Is there something that I can do in C and not in C++? 26. Why preincrement operator is faster than postincrement? 27. What is the difference between "calloc" and "malloc"? 28. What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"? 29. What is Memory Alignment? 30. Explain working of printf. 31. Difference between "printf" and "sprintf". 32. What is "map" in STL? 33. When shall I use Multiple Inheritance? 34. What are the techniques you use for debugging? 35. How to reduce a final size of executable? 36. Give 2 examples of a code optimization.
Define the scope of static variables.
what is the coding of display the factorial of a number using array and function?
Why can't we initialise member variable of a strucutre
wat are the two methods for swapping two numbers without using temp variable??
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output
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;..}
Describe the order of precedence with regards to operators in C.
Why we use conio h in c?
What is include directive in c?