NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Napisać funkcję wymieniającą swoje argumenty typu double.
#include <stdio.h>
void swap(double*,double*);
int main(){
double x=3,y=4;
printf("n X= %f, Y = %f",x,y);
swap(&x,&y);
printf("n X= %f, Y = %f",x,y);
return 0;
}
void swap(double *px, double *py){
double temp;
temp=*px;
*px=*py;
*py=temp;
}



Napisać funkcje obliczające x^n, x^1/n i lognx



#include <stdio.h>
#include <math.h>
int pow(double,double,double*,double*);
int main(){
double x,n,pot=0,pierw=0,logn=0;
printf("n Podaj x: ");
scanf("%lf",&x);
printf("n Podaj n: ");
scanf("%lf",&n);
pot=pow(x,n,&pierw,&logn);
printf("n %lf^%lf = %lf",x,n,pot);
printf("n %lf^1/%lf = %lf",x,n,pierw);
printf("n log%lf(%lf) = %lf",x,n,logn);
getchar();
return 0;
}
int pow(double x, double n, double *pierw,double *logn){
double pot,a;
a=1/n;
pot=pow(x,n);
*pierw=pow(x,a);
*logn=log(x)/log(a);
return pot;
}



Napisać program obliczający sumę . Zastosować funkcję wczytującą
tablicę jednowymiarową wczyt1D, funkcję obliczającą silnię, funkcję obliczającą
pierwiastek 5-tego stopnia oraz funkcję suma obliczającą sumę. W funkcji main()
wywołać funkcję wczyt1D oraz funkcję suma.





#include <stdio.h>
#include <math.h>
void wczt(int n, double x[]);
void druk(int n, double x[]);
double oblicz(int n, double x[]);
double pierw5(double x);
int silnia (int x);
int main(){
double s, x[5];
wczt(5,x);
druk(5,x);
s=oblicz(5,x);
printf("n s=%lf",s);
}
void wczt(int n, double x[]){
int i;
for (i=0;i<n;i++){
printf("n Podaj element x[%d]",i);
scanf("%lf",&x[i]);
}
}
double oblicz(int n, double x[]){
double s; int i;
for(i=0;i<n;i++) s+=pierw5(x[i])/silnia(i);
return s;
}
double pierw5(double x){
int znak=1;
double p;
if (x<0) znak=-1;
p=znak*pow(fabs(x),1/5.0);
return p;
}
int silnia(int x){
int s=1,i;
if (x>0) for(i=1;i<=x;i++) s*=i;
return s;
}
void druk(int n, double x[]){
int i;
for (i=0;i<n;i++) printf("n Element x[%d] = %lf",i,x[i]);
}



Napisać funkcję wczytującą tablicę jednowymiarową, funkcję drukującą tablicę
jednowymiarową, funkcję przekazującą do funkcji wywołującej sumę elementów z
wybranego zakresu indeksów oraz sumę wszystkich elementów tablicy. Wywołać
poszczególne funkcje w funkcji main().


#include <stdio.h>
void wczt(int n, double x[]);
void druk(int n, double x[]);
double suI(int n, double x[], int ind1, int ind2, double *suma);
int main(){
double x[4],suma=0,sumaind=0;
int ind1, ind2;
wczt(4,x);
druk(4,x);
printf("n Podaj ind1: ");
scanf("%d",&ind1);
printf("n Podaj ind2: ");
scanf("%d",&ind2);
sumaind=suI(4,x,ind1,ind2,&suma);
printf("n suma = %f, suma indeksow= %f",suma, sumaind);
}
void wczt(int n, double x[]){
int i;
for (i=0;i<n;i++){
printf("n Podaj element x[%d]",i);
scanf("%lf",&x[i]);
}
}
void druk(int n, double x[]){
int i;
for (i=0;i<n;i++) printf("n Element x[%d] = %lf",i,x[i]);
}
double suI(int n, double x[], int ind1, int ind2, double *suma){
int i;
double s;
for(i=0;i<n;i++) *suma+=x[i];
for(i=0;i<n;i++){
if(i>=ind1&&i<=ind2) s+=x[i];
}
return s;
}



Napisać funkcję wczytującą tablicę dwuwymiarową oraz funkcję drukującą tablicę
dwuwymiarową.




#include<stdio.h>
#include<conio.h>
#include<math.h>
void wczt( int n,int m,int x[n][m]);
void druk( int n, int m ,int x[n][m]);

int main()
{
int a[3][3];
wczt(3,3,a);
druk(3,3,a);
system ("PAUSE");
return 0;
}
void wczt(int n, int m, int x[n][m])
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
printf("n Element [%d][%d]=",i,j);
scanf("%d",&x[i][j]);
}
}
void druk(int n, int m, int x[n][m])
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
printf("%d ",x[i][j]);
printf("n");
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.