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 .

Answers were Sorted based on User's Feedback



Given an int variable n that has already been declared and initialized to a positive value, and a..

Answer / venkadesan

n is not get the values
so,it'a no either printed

Is This Answer Correct ?    0 Yes 0 No

Given an int variable n that has already been declared and initialized to a positive value, and a..

Answer / mahfooz

//1st method..
there is no use of j.as explained below
int j,n=psitive value;
do
{
cout<<"*";
n--;
}while(n!=0);
//2nd we can use j..
int j=0;
do
{
cout<<"*";
j++;
}while(j!=n);

Is This Answer Correct ?    11 Yes 14 No

Post New Answer

More C C++ Errors Interview Questions

quoroum of computer languages?

0 Answers   Infosys,


Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.

1 Answers  


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,


2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]

0 Answers  


#include<>stdio.h> #include<>conio.h> { printf("hello"); void main() getch(); } what the out put of this program and why ......plz clear my answer

10 Answers   Wipro,


void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


how tally is useful?

2 Answers  


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

18 Answers  


#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }

12 Answers   HCL,


class test { int a; public: test(int b):a(b){} void show(){ cout<<a; } }; void main() { test t1; test t2(5); t1.show(); t2.show(); } }

1 Answers  


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


wap for bubble sort

3 Answers  


Categories