What's new
  • Welcome to PHCorner forums. Take a moment to sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Patulong naman po ako kung anong kulang salamat po c++

Social12

Established
Joined
Feb 26, 2018
Messages
314
Reaction
23
Ito po yung problem:Enter your name (first name, family name) and a number then print that number of copies of your name
Sample run

Enter your name: Juan dela Cruz
Enter a number: 10
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz
Juan dela Cruz

tas ito po yung code ko di ko po alam kung anong kulang kasi pag ka enter ko po ng desire number is always 10 po yung lalabas na name

#include<stdio.h>
#include<conio.h>

int main()
{
int ctr;
char name[20];

printf("Enter your name:");
scanf("%s",&name);
gets(name);
printf("Enter a number:");
scanf("%d",&ctr);

for ( ctr=1; ctr=0; ctr++)
{
printf("Juan Dela Cruz\n",ctr);

}
return 0;

}
 
Remove mo yung counter argument sa printf mo like

printf("Juan Dela Cruz\n");

Or based sa inputted mo na values:

#include<stdio.h>
#include<conio.h>

int main()
{
int i;
int ctr;
char name[20];

printf("Enter your name:");
scanf ("%[^\n]%*c", name);

printf("Enter a number:");
scanf("%d",&ctr);

for (i=0; i<ctr; i++)
{
printf("%s\n", name);

}
return 0;

}
 
Last edited:
1 Comment
S
Social12
sir tanong lang po bakit po yung ouput ay Dela cruz lang yung nakikita wala yung juan?
 

FreeAllYouCan-OFFICIAL

Управляющий
Contributor
#include<stdio.h>
#include<conio.h>

int main()
{
int number, ctr;
char name[20];

printf("Enter your name:");
gets(name);
printf("Enter a number:");
scanf("%d",&number);

for ( ctr=1; ctr<=number; ctr++)
{
printf("%s\n",name);
}
return 0;

}
Paulit ulit na tong thread mo
 
Last edited:
S
Social12
ok na po thanks po :D
 

PHC-Dek

Elite
Mali yung condition mo sa for loop.
 
S
Social12
#include<stdio.h>
#include<conio.h>

int main()
{
int number;
int ctr;
char name[20];

printf("Enter your name:");
scanf("%s",&name);
gets(name);
printf("Enter a number:");
scanf("%d",&number);

for ( ctr=1; ctr<=number; ctr++)
{
printf("%s\n",name);
}
return 0;
}

ito po yung gamit kung code galing kay free all you cantas pag ka out put po ay Dela cruz lang nakalagay walang Juan po bakit po kaya?
 

Ambabo

Elite
#include <iostream>

using namespace std;

char name[50];
int total;

int main()
{
cout<<"Enter Your Name : ";
cin.getline(name,50);

cout<<"Enter Number : ";
cin>>total;

for(int a=0; a<total; a++)
{

cout<<a+1<<". "<<name<<endl;
}
return 0;

}
 
Comment

Ambabo

Elite
#include <iostream>

using namespace std;

char name[50];
int total;

int main()
{
cout<<"Enter Your Name : ";
cin.getline(name,50);

cout<<"Enter Number : ";
cin>>total;

for(int a=0; a<total; a++)
{

cout<<a+1<<". "<<name<<endl;
}
return 0;

}
This is a c++
C sharp Kasi gamit mong language eh.
Diko kabisado mga arguments Jan pero Ito try mo
 
Comment

Popular On This Forum

Online statistics

Members online
1,562
Guests online
1,241
Total visitors
2,803

Forum statistics

Threads
823,864
Messages
16,299,911
Members
1,442,639
Top