answersLogoWhite

0


Best Answer

printf and scanf apply to C strings and are not considered type safe for C++ programming. The format specifiers are also quite cryptic. Although they often result in shorter code, it is arguable whether the code is more readable. The C++ standard library is type safe and makes it abundantly clear what is going on.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the advantages of cout and cin intsead of printf and scanf?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is Cin and Cout?

The cin and cout objects are iostream objects somewhat equivalent to stdin and stdout. The equivalent of printf ("Hello World\n"); is cout << "Hello World" << endl; The equivalent of scanf ("%d", &i); is cin >> i;


HOW can a program that outputs the days of the week using switch statement be created?

#include<stdio.h> #include<conio.h> void main() { int n; printf("enter the value of n"); scanf("%d",&n); switch(n) { case1:printf("monday"); break; case2:printf("tueday"); break; case3:printf("wednesday"); break; case4:printf("thursday"); break; case5:printf("friday"); break; case6:printf("saturday"); break; case7:printf("sunday"); break; default:printf("invalid number"); } }


Write a program in c to draw a star and rotate it?

// asterisk pyramid #include<iostream> using namespace std; int main() { int count = 0; for (int width = 0; width <= 10; width++) { for (int alignLeft = width; alignLeft <= 15; alignLeft++) { cout << " "; } for (int space = 1; space < count; space++) { cout << "*"; } cout << endl; count += 2; } return 0; }


Write a program find greatest no between three no?

public class MathExtension { public static decimal getGreatest(decimal d1, decimal d2, decimal d3) { decimal temp = Math.Max(d1, d2); return Math.Max(temp, d3); } } caller: Console.WriteLine(MathExtension.Extension(2m, 3m, 1m)); // prints 3 on console)


How you get the size of arrays from user?

in c simply add three lines in the begining of your program: int x; printf("enter the size of the array to be entered :"); scanf("%d",&x); after that use x as your maximum limit of array in your program. in c++ just replace above printf & scanf statements by cout<<"enter the size of the array to be entered :"; & cin>>x; respectively and do not use brackets.

Related questions

What is Cin and Cout?

The cin and cout objects are iostream objects somewhat equivalent to stdin and stdout. The equivalent of printf ("Hello World\n"); is cout << "Hello World" << endl; The equivalent of scanf ("%d", &i); is cin >> i;


HOW can a program that outputs the days of the week using switch statement be created?

#include<stdio.h> #include<conio.h> void main() { int n; printf("enter the value of n"); scanf("%d",&n); switch(n) { case1:printf("monday"); break; case2:printf("tueday"); break; case3:printf("wednesday"); break; case4:printf("thursday"); break; case5:printf("friday"); break; case6:printf("saturday"); break; case7:printf("sunday"); break; default:printf("invalid number"); } }


Write a program in c to draw a star and rotate it?

// asterisk pyramid #include<iostream> using namespace std; int main() { int count = 0; for (int width = 0; width <= 10; width++) { for (int alignLeft = width; alignLeft <= 15; alignLeft++) { cout << " "; } for (int space = 1; space < count; space++) { cout << "*"; } cout << endl; count += 2; } return 0; }


Write a program find greatest no between three no?

public class MathExtension { public static decimal getGreatest(decimal d1, decimal d2, decimal d3) { decimal temp = Math.Max(d1, d2); return Math.Max(temp, d3); } } caller: Console.WriteLine(MathExtension.Extension(2m, 3m, 1m)); // prints 3 on console)


How you get the size of arrays from user?

in c simply add three lines in the begining of your program: int x; printf("enter the size of the array to be entered :"); scanf("%d",&x); after that use x as your maximum limit of array in your program. in c++ just replace above printf & scanf statements by cout<<"enter the size of the array to be entered :"; & cin>>x; respectively and do not use brackets.


C program to find multiplication table?

#include<stdio.h> void main() { int r,i,j,k; clrscr(); printf("Enter the number range: "); scanf("%d",&r); for(i=1;i<=r;i++) { for(j=1;j<=10;j++) printf("\n%d*%d=%d ",i,j,i*j); //printf("\n"); } getch(); }


Write a C plus plus program to read two integers and display them Use cin and cout statements?

#include#includevoid main(){int a,b;clrscr();printf("Enter two numbers: ");scanf("%d%d",&a,&b);printf("Multiplication of %d and %d is = %d ",a,b,a*b);getch();}


Is printf keyword?

== == What is printf in c or prototype of printf with example (q) What is prototype of printf function ? Explain each term. Ans: Prototype of printf function is : int printf( const char *format ,…) Explanation of each term : Parameter of printf function is : (three continuous dots) : It is called ellipsis. It indicates the variable number of arguments. Example of ellipsis: #include void ellipsis(int a,...); void main() { int a=5,b=10; clrscr(); ellipsis(a,b); getch(); } void ellipsis(int a,...) { printf("%d ",a); } Output:5 So printf function can have any number of variables as an argument.


How do you print the message without using printf and semicolon?

use cout << simple


How do you write a c program to read two numbers and perform addition and subtraction of two matrices?

#include<stdio.h> #include<conio.h> void main() { clrscr(); int a,b,c,n; printf("enter the numbers"); scanf("%D",&n); for(i=0;i<n;i++) a=b; a=c; c=a+b; printf("the sum is %c",); getch(); }


Write a program that input a positive integer n and then prints a triangle of asterisk n lines high and 2n-1 columns wide?

#include<iostream.h> void main(void) { int n; cout<<"Enter A Value For Triangle:"<<endl; cin>>n; cout<<endl; for(int i=n;i>=1;i--) { for(int j=1;j<=i;j++) cout<<" "; for(int k=2*n;k>=2*i;k--) cout<<"*"; cout<<endl; } cout<<endl; cout<<endl; for(int l=0;l<=n-4;l++) cout<<" "; cout<<"ENJOY"<<endl<<endl; }


C program for polynomial multiplication?

/*========================================== calculation of product of two matrix........ written by kr.gauraw ==========================================*/ #include<stdio.h> #include<conio.h> void main() { int mat1[3][3],mat2[3][3],mat3[3][3],i,j,k,sum; clrscr(); printf("\nEnter values for 1st 3 x 3 matrix:\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf("%d",&mat1[i][j]); } } printf("\nEnter values for 2nd 3 x 3 matrix:\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf("%d",&mat2[i][j]); } } printf("\nThe 1st matrix you entered is :\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("%d\t",mat1[i][j]); } printf("\n"); } printf("\nThe 2nd matrix you entered is:\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("%d\t",mat2[i][j]); } printf("\n"); } for(i=0;i<3;i++) { for(j=0;j<3;j++) { sum=0; for(k=0;k<3;k++) { sum=sum+mat1[i][k]*mat2[k][i]; } mat3[i][j]=sum; } } printf("\nThe product of two above matrix is:\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("%d\t",mat3[i][j]); } printf("\n"); } printf("\n\n\nPress any key to exit....."); getch(); }