Display Pattern:
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
…

Answers were Sorted based on User's Feedback



Display Pattern: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 … ..

Answer / yana

listing program c++ 1,1,3,2,5,7,3,9,11,4,13,15

Is This Answer Correct ?    2 Yes 3 No

Display Pattern: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 … ..

Answer / gowtham

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,s=0;
clrscr();
printf("Enter n value:");
scanf("%d",&n);
for(i=0;i<=8230;i++)
{
s=s+1;
}
printf("%d",s);
getch();
}

Is This Answer Correct ?    3 Yes 10 No

Post New Answer

More C++ Code Interview Questions

An array of size 5X5 is given to us. The elements from 1 to 25 are to be inserted in the array, such that starting from a particular position for an element i, the next element i+1can be inserted only at the mentioned positions (u,v), and if these all positions are occupied then it returns giving a count of how many positions have been occupied in the array: (u,v) = (x+/-3 , y) (u,v) = (x , y+/-3) (u,v) = (x+/-2 , y+/-2). Example: if the starting element is 1 with the given positions (1,2), then next element 2 can be placed at any one of the positions marked with *. _ _ _ _ _ 1 _ _ _ * _ _ _ _ _ _ _ * _ _ * _ _ _ _

0 Answers   Nagarro,


Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?

2 Answers   ABC, Qatar University,


main(){int a=5,b 10,c=2, d;a=b c;d=++a=(--c)*2; printf("%d%d%d%d,a,b,c,d; return o;}

1 Answers  


Code for Two Classes for Doing Gzip in Memory?

0 Answers  


what is the best algorithm to sort out unique words from a list of more than 10 million words(1 crore+)? we need the best technique in the terms of execution time.

9 Answers   TCS,






write a program that can LOCATE and INSERT elements in array using c++ programming languages.

0 Answers  


write a program to sort 'n' elemnts using bubble sort

1 Answers   IBM,


What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }

3 Answers   CTS, IBM, Infosys, Qatar University,


program to find the magic square using array

1 Answers  


Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3

2 Answers  


write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?

1 Answers  


develop a program to calculate and print body mass index for 200 employees

0 Answers   Jomo Kenyatta University,


Categories