+ 4
Input and output
Write a program that prints a text of 4 lines consisting of characters, integer values and floating-point values using cout statement.
32 Answers
+ 37
Noel Widler its ok, if it would be homeworks, if i could i would help, but as i see, you have help enough 👍😉
+ 28
an easy way to become the homeworks without any efforts 👍😉
+ 28
Timon Paßlick just thoughts, the question looks like
+ 12
#include<iostream>
#include<conio.h>
void main()
{
clrscr();
int i1, i2, i3, i4;
i1 = 234 , i2 = 360, i3 = 796, i4 = 1344;
float fl1, fl2, fl3, fl4;
fl1 = 34.5, fl2 = 7.12, fl3 = 112.12, fl4 = 3.14;
char ch1, ch2, ch3, ch4;
ch1 = '#', ch2 = '@', ch3 = '>', ch4 = '|';
cout<<"Integers: "<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<endl;
cout<<"Floats: "<<fl1<<" "<<fl2<<" "<<fl3<<" "<<fl4<<endl;
cout<<"Characters: "<<ch1<<" "<<ch2<<" "<<ch3<<" "<<ch4<<endl;
cout<<"We have Displayed the text in 4 lines Using [ cout<< ] statment";
getch();
}
+ 5
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char S='SoloLearn';
int i=100;
float f=3.14;
cout<<"Hello World"<<endl;
cout<<"Character Value: "<<S<<endl;
cout<<"Integer Value: "<<i<<endl;
cout<<"Floating Point Value: "<<f<<endl;
getch();
}
+ 4
#include <iostream>
int main() {
std::cout << R"(characters
1 2 3
1.5 2.3 7.98022)";
}
+ 4
Abhi Varshini
<iostream> should be written without the .h extension.
And neither do you use conio nor is it part of the official language standard.
Apart from that, good example.
+ 4
The location of an error is shown with a line:column pair, at least with this compiler.
4:11 led to "int main" instead of "void main". Your main must return int.
6:11 You forgot "=".
9:1 You forgot a ";".
13:1 Don't use "getch". Tanay just left it away.
+ 2
Sandeep Vaghela Please test your code before posting, that does not compile.
+ 2
tooselfish If it's really homework and he keeps on doing that, one day, noone's going to help him and he'll get an F.
+ 2
//copy and paste
#include <iostream>
using namespace std;
int main() {
int marks = 57;
float avg =32.3;
char grade='A';
cout<<"I am Widler Noel;"<<endl;
cout<<"My total Marks are;"<<marks<<endl;
cout<<"My average is;"<<avg<<endl;
cout<<"My grade is;"<<grade;
}
+ 2
thank you so much bro!!
that’s really helpful.
+ 1
Timon Paßlick I wrote it down without the h it still doesn’t work🤔
+ 1
Noel Widler Without the clrscr()? And does my solution work?
+ 1
you mean take the clescr out?
+ 1
Yep.
+ 1
his my code let me know what i did wrong:
#include <iostream>
using namespace std;
void main() {
int marks = 57;
float avg =32.3;
char grade='A';
cout<<"I am Widler Noel;"<<endl;
cout<<"My total Marks are;"<<marks<<endl;
cout<<"My average is;"<<avg<<endl;
cout<<"My grade is;"<<grade;
getch();
}
+ 1
Does my solution work?
+ 1
int main
+ 1
oh gotcha